<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
	<head>
		<base href="<%=basePath%>">
		<title>修改</title>
		<%@include file="../collect/meta.jsp"%>
		<style type="text/css">
			.input {
				width: 180px;
				height: 25px;
				font-size: 14px
			}
			
			.tbinput {
				width: 180px;
				height: 25px;
				font-size: 14px;
				background-color: #FFFFCC
			}
			
			.error {
				color: red
			}
			
			.success {
				color: green
			}
		</style>
		<script type="text/javascript" charset="utf-8"
			src="${ctx}/calender/WdatePicker.js">
		</script>
		<script type="text/javascript" src="${ctx}/js/returnTop.js"></script>
		<link rel="stylesheet" href="css/radius.css" type="text/css"></link></head>
		<body lang="zh-cn">
		<div class="wrapper">
			<c:import url="/collect/top.jsp"></c:import>
			<div class="main-container" id="main-container">
				<div class="main-container-inner">
					<c:import url="/collect/left.jsp"></c:import>
					<div class="main-content">
						<div class="breadcrumbs" id="breadcrumbs">
							<ul class="breadcrumb">
								<li><i class="icon-home home-icon"></i>积分管理</li>
								<li>积分规则</li>
								<li>时间段规则</li>
								<li>修改</li>
							</ul>
						</div>
						<div class="page-content">
							<div class="row">
								<div class="col-xs-12">
									<div class="tabbable">
										<ul class="nav nav-tabs" id="myTab">
											<li><a href="integralrule!watchEnterpriseIntegralRule">积分等级</a></li>
											<li><a href="bGiveRule!entrygiveValue">注册时积分规则</a></li>
											<li class="active"><a href="bGiveRule!watchBgiveRule">时间段规则</a></li>
										</ul>
									</div>
									<form action="bGiveRule!modifyBgiveRule" method="post"name="updateButton">
										<table width="100%" border="0">
											<tr>
												<td height="40"><div align="right"><font size="2"><strong>积分名称:&nbsp;</strong> </font></div></td>
												<td><font size="1"><input type="text" class="input"name="bGiveRule.name" value="${bGiveRule.name }"></font></td>
												<td><br></td>
											</tr>
											<tr>
												<td height="40"><div align="right"><font size="1"><strong>开始时间:&nbsp;</strong> </font></div></td>
												<td>
													<font size="1"><input type="text" class="Wdate"
															name="bGiveRule.fromTime"
															onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
															readonly="readonly" value="${bGiveRule.fromTime }"
															id="bFromTime"> </font>
												</td>
												<td style="display: none;">
													<input type="text" class="input"
														name="bGiveRule.createTime"
														value="${bGiveRule.createTime}" />
												</td>
												<td style="display: none;">
													<input type="text" class="input" name="bGiveRule.id"
														value="${bGiveRule.id}" id="bId" />
												</td>
												<td><br></td>
											</tr>
											<tr>
												<td height="40"><div align="right"><font size="1"><strong>结束时间:&nbsp;</strong> </font></div></td>
												<td>
													<font size="1"><input type="text" class="Wdate"
															name="bGiveRule.toTime"
															onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
															readonly="readonly" value="${bGiveRule.toTime }"
															id="bToTime"> </font>
												</td>
												<td><br></td>
											</tr>
											<tr>
												<td height="40">
													<div align="right"><font size="1"><strong>积分操作:&nbsp;</strong> </font></div></td>
												<td>
													<font size="1"><input type="text" class="input"
															name="bGiveRule.raiseValue"
															value="${bGiveRule.raiseValue }" id="bRaiseValue">
													</font>
												</td>
												<td><br></td>
											</tr>
											<tr>
												<td height="40">
													<div align="right"><font size="1"><strong>奖励规则:&nbsp;</strong> </font></div>
												</td>
												<td>

													<c:if test="${bGiveRule.type==2 }">
														<font size="1">
															<select name="bGiveRule.type">
																<option value="2">积分翻倍</option>
																<option value="3">积分增加</option>
															</select> 
														</font>
													</c:if>
													<c:if test="${bGiveRule.type==3 }">
														<font size="1">
															<select name="bGiveRule.type">
																<option value="3">积分增加</option>
																<option value="2">积分翻倍</option>
															</select> 
														</font>
													</c:if>
												</td>
												<td><br></td>
											</tr>
											<tr>
												<td height="40"><div align="right"><font size="1"><strong>是否启用:&nbsp;</strong> </font></div></td>
												<td>
													<c:if test="${bGiveRule.state==2 }">
														<font size="1">
															<select name="bGiveRule.state">
																<option value="2">不启用</option>
																<option value="1">启用</option>
															</select> 
														</font>
													</c:if>
													<c:if test="${bGiveRule.state==1 }">
														<font size="1">
															<select name="bGiveRule.state">
																<option value="1">启用</option>
																<option value="2">不启用</option>
															</select> 
														</font>
													</c:if>
													<div style="color: red">
												</td>
												<td><br></td>
											</tr>
											<tr>
											<tr>
												<td height="40"><br></td>
												<td><font size="1"><input type="button"class="btn btn-primary radius" id="but" value="修改"> <a class="btn btn-primary radius" href="bGiveRule!watchBgiveRule">返回</a></font></td>
											</tr>
										</table>
									</form>
									<c:if test="${message!=null}">
										<font size="1"><LABLE>${message }<LABLE>
										</font>
									</c:if>
								</div>
							</div>
						</div>
					</div>
				</div>
				<a href="#" id="btn-scroll-up"
					class="btn-scroll-up btn btn-sm btn-inverse"
					style="position: fixed; bottom: 0;"> <i
					class="icon-double-angle-up icon-only bigger-110"></i> </a>
			</div>
			<div class="push"></div>
		</div>
		<c:import url="/collect/down.jsp"></c:import>

		<script type="text/javascript">
		$('#but').click(function() {
			var bRaiseValue = $('#bRaiseValue').val();
				var bFromTime = $('#bFromTime').val();
				var bToTime = $('#bToTime').val();
				var bId = $('#bId').val();
	
				if (/^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$/.test(bRaiseValue)) {
					
					$.ajax( {
						async : false,
						url : "bGiveRule!checkTime",
						type : "post",
						data : {
							"bFromTime" : bFromTime,
							"bToTime" : bToTime,
							"bId" : bId
						},
						datatype : "json",
						success : function(data) {
							var d = eval("(" + data + ")");
							if (d.temp != "") {
								alert(d.temp);
							} else {
								updateButton.submit();
							}
	
						},
						error : function(request) {
							alert("Connection error");
						}
					});
	
				}else{
					alert('积分操作填写有误');
				}
	
			});
			 //防收回；积分规则：$修改
			$('.jifenguanli > ul').show();
			$('.jifenguanli > ul > li > a').eq(0).css("color","red");     
		</script>
	</body>
</html>